import base from "../api/base";
import axios from "@/request/http"; // 导入http中创建的axios实例

export default {
  syncUserInfo({ state, commit }, data) {
    console.log(data);
    axios
      .get(`${base.yxf}/user/obtain/userinfo?userId=${state.user.userId}`)
      .then(res => {
        if (res.data.code === 200) {
          console.log(res.data.data);
          let resdata = res.data.data;
          let user = {
            isLogin: true,
            phone: resdata.phone, //用户名 手机号或者字符串
            avatar: resdata.avatar,
            token: resdata.token?resdata.token:state.user.token,
            userId: resdata.userId,
            nickName: resdata.nickName,
            userName:resdata.userName,
            email:resdata.email,
            age: resdata.age,
            sex: resdata.sex,
            createTime: resdata.createTime,
            status: resdata.status,
            integralOne: resdata.integralOne,
            integralTwo: resdata.integralTwo,
            gainWeight: resdata.gainWeight,
            userWaltVo: resdata.userWaltVo
          };
          commit("saveuserdata", user);
        }
      });
  }
};
